package smartcampus.scjava.controller.forth;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import smartcampus.scjava.POJO.DO.Equipment;
import smartcampus.scjava.POJO.DO.EquipmentInventoryRecord;
import smartcampus.scjava.custom.ResultVO;
import smartcampus.scjava.service.IEquipmentInventoryRecordService;

import javax.annotation.Resource;

/**
 * <p>
 * 器材库存记录表 前端控制器
 * </p>
 *
 * @author xian
 * @since 2023-12-05
 */
@RestController
@RequestMapping("/equipment-inventory-record")
public class EquipmentInventoryRecordController {


    @Resource
    private IEquipmentInventoryRecordService inventoryRecordService;


    @RequestMapping("/listPage")
    public ResultVO<?> listPageBook(Integer  pageNum, Integer pageSize, String word) {
        if (pageNum == null || pageSize == null) {
            return ResultVO.error("分页参数错误");
        }

        Page<EquipmentInventoryRecord> page = new Page<>(pageNum,pageSize);
        QueryWrapper<EquipmentInventoryRecord> query = new QueryWrapper<>();
        if (StringUtils.hasText(word)) {
            query.lambda().like(EquipmentInventoryRecord::getEquipmentName,word);
        }

        inventoryRecordService.page(page,query);
        return ResultVO.success(page);
    }
}
